package com.bingxue.edu.management.education.controller;

import com.bingxue.edu.framework.common.model.PageQuery;
import com.bingxue.edu.framework.common.model.Pagination;
import com.bingxue.edu.framework.common.model.Response;
import com.bingxue.edu.framework.security.ApiResource;
import com.bingxue.edu.management.education.model.entity.EnrollChangeRecord;
import com.bingxue.edu.management.education.model.query.EnrollChangeRecordQuery;
import com.bingxue.edu.management.education.model.resp.EnrollChangeRecordResp;
import com.bingxue.edu.management.education.service.EnrollChangeRecordService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 报名变更记录
 *
 * @author zq
 * @since 2024/08/26
 */
@Tag(name = "报名变更记录")
@RestController
@RequestMapping("/education/enrollment/change")
@RequiredArgsConstructor
public class EnrollChangeRecordController {


    private final EnrollChangeRecordService enrollChangeRecordService;

    @Operation(summary = "分页查询：转班/调课/退班/退课变更记录列表")
    @ApiResource("edu:class-change:manage")
    @GetMapping("/page")
    public Response<Pagination<EnrollChangeRecordResp>> page(EnrollChangeRecordQuery query, @Validated PageQuery pageQuery) {
        return Response.success(Pagination.of(enrollChangeRecordService.queryPage(query, pageQuery)));
    }

    @Operation(summary = "变更信息查询：传报名id")
    @ApiResource("edu:class-change:manage")
    @GetMapping("/query/{id}")
    public Response<List<EnrollChangeRecord>> queryChange(@PathVariable String id) {
        return Response.success(enrollChangeRecordService.queryChange(id));
    }
}
